using System.Collections;
using UnityEngine;

public class LobbyPlayerAnimationController : MonoBehaviour
{
	public float minSecondsToAnimation = 2f;

	public float maxSecondsToAnimation = 3f;

	private Animator _anim;

	private bool _isWaiting;

	private void Start()
	{
		_anim = base.gameObject.GetComponent<Animator>();
		if (_anim == null)
		{
			BCWDebug.Log("Can't find animator");
		}
	}

	private void OnEnable()
	{
		_isWaiting = false;
	}

	private void FixedUpdate()
	{
		Idle();
		if (!_isWaiting)
		{
			StartCoroutine(Wait(Random.Range(minSecondsToAnimation, maxSecondsToAnimation)));
		}
	}

	private IEnumerator Wait(float time)
	{
		_isWaiting = true;
		yield return new WaitForSeconds(time);
		_isWaiting = false;
		ChooseAnimation();
	}

	public void Reload()
	{
		_anim.SetBool("Reload", true);
	}

	public void Turn()
	{
		_anim.SetBool("TurnAround", true);
	}

	public void Idle()
	{
		_anim.SetBool("Reload", false);
		_anim.SetBool("TurnAround", false);
	}

	private void ChooseAnimation()
	{
		float num = Random.Range(0, 2);
		if (num < 1f)
		{
			Reload();
		}
		if (num >= 1f)
		{
			Turn();
		}
	}
}
